<template>
  <div class="page-login">
    <h2>登录页面</h2>

    <button @click="handleClick">点我，就登录成功</button>
  </div>
</template>

<script>
export default {
  methods: {
    handleClick() {
      // 写入 token
      localStorage.setItem("token", "abcd");

      // 获取 url 地址中的 redirect 参数
      const redirect = decodeURIComponent(
        this.$route.query.redirect || "/dashboard"
      );

      // 跳转
      this.$router.replace(redirect);
    },
  },
};
</script>

<style scoped>
.page-login {
  height: 100%;
  background-color: green;
}
</style>
